<?php
/*
 * Copyright 2011 by Alex Lucyk, Jesus Navarro, and Allen Tucker.
 * This program is part of RMH Homeroom, which is free software.
 * It comes with absolutely no warranty.  You can redistribute and/or
 * modify it under the terms of the GNU Public License as published
 * by the Free Software Foundation (see <http://www.gnu.org/licenses/).
*/

/*
 * Person class for RMH Homeroom
 * @author Alex Lucyk
 * @version May 1, 2011
 */

class Person {
    private $id;               // id (unique key) = first_name . phone1
    private $last_name;        // last name - string
    private $first_name;       // first name - string
    private $address;              // address - string
    private $city;                 // city - string
    private $state;                // state - string
    private $zip;                  // zip code - integer
    private $phone1;               // primary phone
    private $phone2;               // alternate phone
    private $email;            // email address
    
    private $patient_name;     // patient name
    private $patient_birthdate; // format: 11-03-12
    private $patient_relation;  // person's relation to patient; e.g., parent, uncle, etc.
    private $checkin_dates;     // array of dates recording checkin ; e.g., 11-03-12
    private $checkout_dates;    //array of dates recording checkout
    private $mgr_notes;            // manager notes
    private $sw_notes;             // social worker notes
    private $type;             // array of 'manager', 'socialworker', 'guest', 'volunteer'
    private $password;         // password for database access: default = $id

        /**
         * constructor for a Person
         */
    function __construct($last_name, $first_name, $address, $city, $state, $zip, $phone1, $phone2, $email,
                         $type, $patient_name, $patient_birthdate, $patient_relation, $password){                
        $this->id = $first_name . $phone1; 
        $this->last_name = $last_name;
        $this->first_name = $first_name;
        $this->address = $address;
        $this->city = $city;
        $this->state = $state;
        $this->zip = $zip;
        $this->phone1 = $phone1;
        $this->phone2 = $phone2;
        $this->email = $email;
      
        $this->patient_name = $patient_name;
        $this->patient_birthdate = $patient_birthdate;
        $this->patient_relation = $patient_relation;
                
        $this->type = explode(',',$type);
        $this->checkin_dates = array();
        $this->checkout_dates = array(); 
        if ($password=="")
            $this->password = md5($this->id);
        else $this->password = $password;       
    }
    //getter functions
    function get_id() {
        return $this->id;
    }
    function get_first_name() {
        return $this->first_name;
    }
    function get_last_name() {
        return $this->last_name;
    }
    function get_address() {
        return $this->address;
    }
    function get_city() {
        return $this->city;
    }
    function get_state() {
        return $this->state;
    }
    function get_zip() {
        return $this->zip;
    }
    function get_phone1() {
        return $this->phone1;
    }
    function get_phone2() {
        return $this->phone2;
    }
    function get_email(){
        return $this->email;
    }
    function get_patient_name(){
        return $this->patient_name;
    }
    function get_patient_birthdate(){
        return $this->patient_birthdate;
    }
    function get_patient_relation(){
        return $this->patient_relation;
    }
    function get_type(){
        return $this->type;
    }
    //returns true if the person has type $t
    function check_type($t){
        if (in_array($t, $this->type))
            return true;
        else
            return false;
    }
    function get_checkin_dates(){
        return $this->checkin_dates;
    }
    function get_checkout_dates(){
        return $this->checkout_dates;
    }
    
    function get_mgr_notes(){
        return $this->mgr_notes;
    }
    function get_sw_notes (){
        return $this->sw_notes;
    }
    function get_password () {
        return $this->password;
    }
    //setter functions
    function set_last_name($ln) {
        $this->last_name = $ln;
    }
    function set_address($ad) {
        $this->address = $ad;
    }
    function set_city($c) {
        $this->city = c;
    }
    function set_state($s) {
       $this->state = $s;
    }
    function set_zip($z) {
        $this->zip = $z;
    }
    function set_phone2($p2) {
        $this->phone2 = $p2;
    }
    function set_email($em){
        $this->email = em;
    }
    function add_type ($t) {
        $this->type[] = $t;
    }
    function set_patient_name($pn){
        $this->patient_name = $pn;
    }
    function set_patient_birthdate ($pbd){
        $this->patient_birthdate = $pbd;
    }
    function set_patient_relation ($pr){
        $this->patient_relation = $pr;
    }
    function set_password ($new_password) {
        $this->password;
    }
    function set_mgr_notes($mnote){
        $this->mgr_notes = $mnote;
    }
    function set_sw_notes ($snote){
        $this->sw_notes = $snote;
    }
    //adds the provided date to the checkin array
    function add_checkin_date($date){
        $this->checkin_dates[] = $date;
    }
    //adds the provided date to the checkout array
    function add_checkout_date($date){
        $this->checkout_dates[] = $date;
    }
    
}
?>
